import request, { queryJson } from '@u/request/index';
// 生成md5
export function getMd5() {
  var d = new Date().getTime();
  var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
    var r = (d + Math.random() * 16) % 16 | 0;
    d = Math.floor(d / 16);
    return (c == 'x' ? r : (r & 0x3) | 0x8).toString(16);
  });
  return uuid;
}
// const http = "http://10.8.187.211:21002"
// 切片上传
export function CutFileUpload(paras: any, data: any) {
  return request.post(`/api/sysFile/aliCutFileUpload${queryJson(paras)}`, data);
}
// 整合上传
export function MergeFileUpload(paras: any, config: object) {
  return request.post(`/api/sysFile/aliMergeFile${queryJson(paras)}`, undefined, config);
}
// 附件上传
export function AliyunUploadFileStream(params: any, fileData: FormData, config: object) {
  return request.post(`/api/sysFile/uploadSysFile${queryJson(params)}`, fileData, config);
}
// 文件入库
export function SysFileToLibrary(data: any) {
  return request.put(`/api/sysFile/SysFileToLibrary`, data);
}
// 文件删除
export function DelFile(data: any) {
  return request.delete(`/api/sysFile/sysFile`, {
    data,
  });
}

export function fileUpload(params: FormData, config: object) {
  return request.post('/api/file/fileUpload', params, config);
}

export function fileDelete(params: object) {
  return request.post('/api/file/fileDelete', params);
}
